/**
 * @author: jever
 * @date: 2019/3/12
 * @description:  usercard.js
 */

import React from 'react'
import PropTypes from 'prop-types'
import {WhiteSpace, WingBlank, Card} from "antd-mobile";
import {withRouter} from "react-router-dom";

@withRouter

class UserCard extends React.Component {
    static propTypes = {
        userList: PropTypes.array.isRequired
    }

    // constructor(props) {
    //     super(props)
    // }
    handleClick(v) {
        this.props.history.push(`/chat/${v._id}`)
    }

    render() {
        return (
            <WingBlank>
                <WhiteSpace></WhiteSpace>
                {this.props.userList.map(v => (
                    v.avatar ? (
                        <Card
                            onClick={() => this.handleClick(v)}
                            key={v._id}
                        >
                            <Card.Header
                                title={v.user}
                                thumb={require(`../image/${v.avatar}.jpg`)}
                                thumbStyle={{width: 20}}
                                extra={<span>{v.title}</span>}
                            >
                            </Card.Header>
                            <Card.Body>
                                {v.type === 'boss' ? <div>公司：{v.company} </div>:null}
                                {v.desc.split('\n').map(d => (
                                    <div key={d}>{d}</div>
                                ))}
                                {v.type === 'boss' ? <div>薪资：{v.money} </div>:null}
                            </Card.Body>
                        </Card>) : null
                ))}
            </WingBlank>
        )
    }
}

export default UserCard